package cn.bs.allensocket.mythread;

import static java.lang.Thread.sleep;

/**
 * Created by Allen on 2014/11/4.
 */
public class MyRunnable implements Runnable {
    private Foo foo = new Foo();
    public static void main(String args[]){
        MyRunnable r = new MyRunnable();
        Thread ta = new Thread(r,"Allen");
        Thread tb = new Thread(r,"ROC");
        ta.start();
        tb.start();
    }
    @Override
    public void run(){
        for (int i = 0 ;i < 3 ; i++){
            this.foo.fix(30);
            try {
                sleep(1);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + ":当前foo对象的X值=" + this.foo.getX());
        }
    }
}
